package com.yunhai.model.base;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Date;

@Data
public class BaseEntity {

    //该条记录的状态
    @JsonIgnore
    @TableLogic
    private Integer isDeleted;
    //创建日期
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @TableField( value="create_time", fill=FieldFill.INSERT )
    private LocalDateTime createTime;
    //创建人
    @JsonIgnore
    @TableField( value="create_by", fill=FieldFill.INSERT )
    private String createBy;
    //更新时间
    @JsonFormat( pattern = "YYYY-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @TableField( value="update_time", fill= FieldFill.INSERT_UPDATE )
    private LocalDateTime updateTime;
    //更新人
    @JsonIgnore
    @TableField( value="update_by", fill= FieldFill.INSERT_UPDATE )
    private String updateBy;

}
